package com.zyf.chapter01.principle.SOLID.SRP;

import com.zyf.chapter01.principle.SOLID.SRP.utils.Gson;

import java.util.Collections;
import java.util.Map;

/**
 * 职责更加单一的序列化类，只包含反序列化功能
 * @author yifeng
 */
public class Deserializer {
	private static final String IDENTIFIER_STRING = "UEUEUE;";
    private Gson gson;
    
    public Deserializer() {
    	this.gson = new Gson();
    }
	
 public Map<String, String> deserialize(String text) {
    	if(!text.startsWith(IDENTIFIER_STRING)) {
        	return Collections.emptyMap();
        }
        String gsonStr = text.substring(IDENTIFIER_STRING.length());
        return gson.fromJson(gsonStr, Map.class);
    }
}